package controllers;

import java.util.Map;

import play.Logger;
import play.mvc.Catch;
import play.mvc.Controller;
import services.UserService;
import time.Interval;

import com.google.gson.JsonObject;

public class Application extends Controller {

	public static void index() {
		render();
	}

	public static void present() {
		renderArgs.put("listing", "present");
		renderArgs.put("users",
				UserService.allPresent(0, 100, Interval.today()));
		renderTemplate("Application/list.html");
	}

	public static void absent() {
		renderArgs.put("listing", "absent");
		renderArgs
				.put("users", UserService.allAbsent(0, 100, Interval.today()));
		renderTemplate("Application/list.html");
	}

	public static void sick() {
		renderArgs.put("listing", "sick");
		// renderArgs.put("users", UserService.allSick(0, 100));
		renderTemplate("Application/list.html");
	}

	public static void holiday() {
		renderArgs.put("listing", "holiday");
		// renderArgs.put("users", UserService.allHoliday(0, 100));
		renderTemplate("Application/list.html");
	}

	@Catch
	@SuppressWarnings("unused")
	private static void catchAll(Exception ex) {
		Logger.info("Some Bad error " + ex.getMessage());
	}

	@SuppressWarnings("unused")
	private static void sendErrors(Map<String, String> extra) {
		JsonObject res = new JsonObject();
		res.addProperty("error", true);
		renderJSON(res);
	}

}